interface Monitor{//显示器

}
interface Host{
    
}
class  Monitor27inch implements Monitor{

}

class  AppleHost implements Host{
    
}
class Computer{
    public monitor=new Monitor27inch()
    public host=new AppleHost()
    boostrap(){
        console.log('启动电脑',this);
        
    }
}

const computer=new Computer()
console.log(11,computer);

class Computer2{
    // public monitor=new Monitor27inch()
    // public host=new AppleHost()
    constructor(public monitor:Monitor,public host:Host){

    }
    boostrap(){
        console.log('启动电脑',this);
        
    }
}
const computer2=new Computer()
console.log(22,computer,new Map());
class Container{
    private instances= new Map()
    bind<T>(key:string,creater:()=>void){
        if(!this.instances.has(key)){
            this.instances.set(key,creater())
        }
        console.log(33000,this.instances);

    }
    resolve(key:string){
        return this.instances.get(key)
    }
}


const container=new Container()
container.bind<Monitor>('Monitor',()=>new Monitor27inch())
container.bind<Host>('Host',()=>new AppleHost())
container.bind<Computer2>('Computer2',()=>new Computer2(container.resolve('Monitor'),container.resolve('Host')))
console.log(23,container);

export {}